var system: any = getSystem()
function getSystem(): any {
  try {
    return system = (window as any).jthisJsObject.jthis;
  }
  catch (_err) {
    try {
      return system = (window as any).wdphisJsObject.wdphis
    } catch (_err) {
      return
    }
  }
}
export function session(name: string, val: any = undefined) {
  if (system) {
    if (val === undefined) {
      return JSON.parse(system.varget('that', name) || 'null');
    } else if (val === null) {
      system.varpost('that', name, JSON.stringify(val));
    } else {
      system.varpost('that', name, JSON.stringify(val));
    }
  } else {
    if (val === undefined) {
      return JSON.parse(sessionStorage.getItem(name) || 'null')
    } else if (val === null) {
      sessionStorage.removeItem(name)
    } else {
      sessionStorage.setItem(name, JSON.stringify(val || ''))
    }
  }
}